package problema045;


public class TriPentHex {
	
	static long tri = 0;
	
	public static void main(String[] args){
		cumpleLas3();
	}

	public static void cumpleLas3(){
		long act = 0, cant = 0;
		while(true){
			act = tri();
			if(pent(act) && hex(act)){
				System.out.println(act);			
				cant++;
				if(cant == 3) break;
			}
		}		
	}
	
	public static long tri(){
		tri++;
		return (tri * (tri + 1))  / 2;
	}
	
	public static boolean pent(long i){
		double act = i;
		act *= 24; act++;
		act = Math.sqrt(act);
		act++; act /= 6;
		int ent = (int) act;
		return ent == act;
	}
	
	public static boolean hex(long i){
		double act = i;
		act *= 8; act++;
		act = Math.sqrt(act);
		act++; act /= 4;
		int ent = (int) act;
		return ent == act;		
	}
}
